package com.ccjt.eip.web.controller;

import com.ccjt.eip.web.services.I${voEntity}Service;
import com.ccjt.eip.web.vo.${voEntity};
import com.ccjt.eip.web.vo.ResultDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;

/**
 *
 * @author
 * @date ${creatTime}
 */
@RestController
@RequestMapping("/${voEntity}")
public class ${voEntity}Controller {

    @Autowired
    private I${voEntity}Service ${voEntityLowCase}Service;

    @RequestMapping("/index")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("index");
        return modelAndView;
    }

    @RequestMapping("/form")
    public ModelAndView editform(){
        ModelAndView modelAndView = new ModelAndView("form");
        return modelAndView;
    }

    @RequestMapping("/grid")
    public Map<String,Object> grid(${voEntity} ${voEntityLowCase},Integer page,Integer rows){
        Map<String,Object> data = ${voEntityLowCase}Service.list(${voEntityLowCase},page,rows);
        return data;
    }

    @RequestMapping("/save")
    public ResultDto save(${voEntity} ${voEntityLowCase}){
        ResultDto resultDto = ${voEntityLowCase}Service.saveOrUpdate${voEntity}(${voEntityLowCase});
        return resultDto;
    }

    @RequestMapping("/del")
    public ResultDto del(String ids){
        ResultDto resultDto = ${voEntityLowCase}Service.delete${voEntity}ByIds(ids.split(","));
        return resultDto;
    }

    @RequestMapping("/get${voEntity}")
    public ${voEntity} get${voEntity}(int id){
        return ${voEntityLowCase}Service.get${voEntityLowCase}ById(id);
    }

}
